program main
    implicit none
    integer(kind=4) :: num
    logical,external :: judge
    write(*,*) 'Enter :'
    read(*,*) num
    if (judge(num))then
        write(*,*) "Yes ,it's a prime."
    else
        write(*,*) "No, it isn't a prime."
    end if
end program

logical function judge(n)
    integer :: n,i
    real :: r
    !logical :: judge=.true.
    judge=.true.
    i=2
    if (n==2) then
        goto 2
    end if
    r = sqrt(real(n))
    do while(i<=int(r))
        if(mod(n,i)==0) then
            judge = .false.
            goto 2
        end if
        i=i+1
    end do
2   continue
end function
